package com.jyxy.service.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.alibaba.druid.util.StringUtils;
import com.mysql.fabric.xmlrpc.base.Array;

public class FullArrangement {
	private static List<String> reslist=new ArrayList<String>();
	private static  String tsidKey=null;
	private static  String ttime=null;
	public static void main(String[] args) {
	    String[] array={"1","2","3","4"};
	    List<String> s=FullArrangement.getMd5List(array);
	    System.out.println(s);
	    
	}
	public static List<String> getMd5List(String[] arrs) {
	    allSort(arrs, 0, arrs.length-1);
	    return reslist;
	}
	static void allSort(String[] array,int begin,int end){
		if(end==-1) {
			String md5s=Md5Util.encrypt("", tsidKey, ttime);
	        reslist.add(md5s);
		}
	  
	    if(begin==end){
	    	String str="";
	        for (String string : array) {
	        	str+=string;
			}
	        String md5s=Md5Util.encrypt(str, tsidKey, ttime);
	        reslist.add(md5s);
	        return;
	    }
	 
	    for(int i=begin;i<=end;i++){
	        swap(array,begin,i );
	        allSort(array, begin+1, end);
	        swap(array,begin,i );
	    }
	}

	static void swap(String[] array,int a,int b){
	    String tem=array[a];
	    array[a]=array[b];
	    array[b]=tem;
	}
	public static List<String> getMd5List(String[] arrs, String sidKey, String time) {
		// TODO Auto-generated method stub
		 tsidKey=sidKey;
		 ttime=time;
		 allSort(arrs, 0, arrs.length-1);
		 return reslist;
	}
}
